package com.fs.controller;

import com.fs.pojo.GoodsCart;
import com.fs.service.GoodsCartService;
import com.fs.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cart")
public class CartController {

    @Autowired
    private GoodsCartService goodsCartService;

    @PostMapping("/add")
    public ResultVO cart(@RequestBody GoodsCart cart) {
        return goodsCartService.add(cart);
    }

    @GetMapping("/list")
    public ResultVO list(){
        return goodsCartService.list(null);
    }

    @DeleteMapping("/del")
    public ResultVO del(Integer[] ids){
        return goodsCartService.del(ids);
    }

    @DeleteMapping("/delAll")
    public ResultVO delAll(){
        return goodsCartService.delAll();
    }

    @PutMapping("/num")
    public ResultVO changeNum(@RequestBody GoodsCart goodsCartEntity){
        return goodsCartService.changeNum(goodsCartEntity);
    }

    @GetMapping("/cartNum")
    public ResultVO getCartNum(){
        return goodsCartService.list(null);
    }
}
